package com.atguigu.es.repository;

import com.atguigu.es.vo.User;
import org.springframework.data.elasticsearch.annotations.Query;
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;

import java.util.List;

//必须使用泛型配置 要操作的索引的bean
public interface UserRepositoy  extends ElasticsearchRepository<User,Long> {
    //findByPriceBetween
    List<User> findBySalaryBetween(Double from,Double to);
    //findByNameLike
    List<User> findByUsernameLike(String username);
    //希望查询工资区间的数据
    @Query("{\n" +
            "    \"bool\": {\n" +
            "      \"must\": [\n" +
            "        {\n" +
            "          \"range\": {\n" +
            "            \"salary\": {\n" +
            "              \"gte\": ?0,\n" +
            "              \"lte\": ?1\n" +
            "            }\n" +
            "          }\n" +
            "        }\n" +
            "      ]\n" +
            "    }\n" +
            "  }") //@Query注解实现自定义方法  @Query中 编写DSL语句
    List<User> qUsersBySalary(Double from,Double to);
}
